﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace ROrganizer.Client
{
    public class ImdbFacility
    {
        internal static readonly Regex MovieRegex = new Regex("http://(www\\.)?imdb\\.com/title/tt(?<id>[0-9]{7})/?");

        public bool IsValidLink(string link)
        {
            return ImdbFacility.MovieRegex.IsMatch(link ?? String.Empty);
        }

        public string GetId(string link)
        {
            return ImdbFacility.MovieRegex.Match(link ?? String.Empty).Groups["id"].Value;
        }

        public string FormatLink(string id)
        {
            return String.Format("http://www.imdb.com/title/tt{0}", id);
        }
    }
}
